﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using System.Web.Mvc;
using System.Web.Routing;

namespace MvcAreasApplication
{
    public class CustomFilter : ActionFilterAttribute
    {
        public override void OnAuthorization(
           AuthorizationContext filterContext)
        {
            Message(filterContext.RouteData);
        }

        public override void OnActionExecuted(
           ActionExecutedContext filterContext)
        {
            Message(filterContext.RouteData);
        }

        public override void OnActionExecuting(
           ActionExecutingContext filterContext)
        {
            Message(filterContext.RouteData);
        }

        public override void OnResultExecuted(
           ResultExecutedContext filterContext)
        {
            Message(filterContext.RouteData);
        }

        public override void OnResultExecuting(
           ResultExecutingContext filterContext)
        {
            Message(filterContext.RouteData);
        }

        public void Message(RouteData route)
        {
            var controller = route.Values["controller"];
            var action = route.Values["action"];

            var message = String.Format(
           "controller={0}, action={1}", controller, action);

            Debug.WriteLine(message);
        }
    }

}